package com.uphone.magicleafteacher;

import com.radish.baselibrary.base.BaseApplication;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;
import com.uphone.magicleafteacher.dragger.component.DaggerMyAppComponent;
import com.uphone.magicleafteacher.dragger.component.MyAppComponent;
import com.uphone.magicleafteacher.dragger.module.MyAppModule;
import com.uphone.magicleafteacher.http.HttpManager;

/**
 * author : SuMeng
 * e-mail : 986335838@qq.com
 * time   : 2019/05/24
 * desc   : xxxx 描述
 * wanglaoshi
 * diyipwd
 * <p>
 * 1.作业批改 作业为多图片，批改作业为单一图片
 * 2.bookReadDetail接口缺少“积分”字段
 * 3.复述--批改音频，图片是书籍的封面，批改时，在书籍封面上批改，这个需求是不是有问题
 *      2个接口
 *
 *
 * bug量：8
 */
public class MyApp extends BaseApplication {
    private HttpManager mHttpManager = null;


    protected void init() {
        //初始化网络
        mHttpManager = new HttpManager();

        initBugly();
    }

    private void initBugly() {
        Bugly.init(getApplicationContext(), "a7c1082f9f", true);
        Beta.autoDownloadOnWifi = true;
        Beta.autoInit = true;
        Beta.autoCheckUpgrade = true;
        Beta.enableHotfix = true;
    }

    /**
     * 关联apiService
     *
     * @param clz
     * @param <T>
     * @return
     */
    public static <T> T apiService(Class<T> clz) {
        return (getInstance()).mHttpManager.getService(clz);
    }

    public static synchronized MyApp getInstance() {
        return (MyApp) mInstance;
    }


    public static MyAppComponent getAppComponent() {
        return DaggerMyAppComponent.builder()
                .myAppModule(new MyAppModule(getInstance()))
                .build();
    }


}
